﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
using Iridescent.Models;

namespace Iridescent.ViewModels
{
    public class CourseHubViewModel
    {
        public string CourseName { get; private set; }
        public IQueryable<Grouping<DayOfWeek, Course>> Arrangements
        {
            get;
            private set;
        }

        public CourseHubViewModel(string courseName)
        {
            CourseName = courseName;

            Arrangements =
                from c in App.LocalDatabase.Courses
                where c.Name == courseName
                group c by c.Day into g
                select new Grouping<DayOfWeek, Course>(g);
        }
    }

    public class Grouping<Tkey, TElement> : List<TElement>
    {
        public Grouping(IGrouping<Tkey, TElement> g)
            : base(g)
        {
            Key = g.Key;
        }

        public Tkey Key { get; private set; }
    }
}
